test(tasks): cover server-side execute_agent (BUILD) path (#749)#829
Conversation
Adds an API-level test that calls POST /tasks/{id}/start?execute=true with
MockProvider injected (CODEFRAME_LLM_PROVIDER=mock), polls the run to a
terminal status, and asserts the agent-dispatch branch (_run_agent ->
runtime.execute_agent) completes and produces output. Joins the endpoint's
fire-and-forget worker thread before teardown to avoid a DB-race on the
temp workspace.
Closes #749
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 44 minutes Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
ReviewThis PR adds One finding worth a look:
Nothing else stood out — the thread-snapshot/join approach to avoid the teardown DB race is sound (starlette's 🤖 Generated with Claude Code |
Address claude-review: run_output_exists() is only path.exists(), and RunOutputLogger creates the file at execute_agent start, so existence only proved the run started. Assert st_size > 0 to prove the BUILD path actually emitted output.
|
Thanks — good catch on the |
ReviewRe-reviewed after the fix in 4ca329b. The PR adds Previously flagged issue — confirmed fixed. My earlier review noted that Nothing new found. I re-traced the rest of the test against the current code:
No new correctness, security, or coverage issues stood out in this pass. The 30s poll deadline / 10s join timeout are reasonable for CI and, per the PR description, the test has been run repeatedly without flaking. 🤖 Generated with Claude Code |
Summary
Closes #749. Adds the missing API-level test for the task execute / BUILD path.
The existing
/tasks/{id}/starttests all omitexecute=true, so the agent-dispatch branch (_run_agent→runtime.execute_agent) had zero API-level coverage — a regression in server-side agent dispatch would slip through.What the test does
TestTasksV2Execution::test_start_task_execute_runs_agent_to_terminal:CODEFRAME_LLM_PROVIDER=mock— the router builds the provider throughget_provider("mock"); its text-only response makes the ReAct agent complete on the first iteration (react_agent.py:518).POST /tasks/{id}/start?execute=true, asserts the immediateexecutingresponse.GET /tasks/{id}/rununtil the run leavesRUNNING, asserts it reachesCOMPLETED.streaming.run_output_exists) — evidence the BUILD path actually emitted events.Acceptance criteria
✅ Met.
Notes
/start?execute=trueendpoint dispatchesexecute_agentin a fire-and-forget daemon thread. The test snapshots threads before the POST and joins the new worker before assertions/teardown, so the still-draining thread can't touch the temp workspace DB after the fixture removes it (eliminated an intermittentunable to open database filelog). Verified stable across repeated runs.Testing
uv run pytest tests/ui/test_v2_routers_integration.py→ 74 passeduv run ruff check tests/ui/test_v2_routers_integration.py→ clean